package com.zhiche.lisa.bms.controller.utils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.zhiche.lisa.bms.dao.model.arfund.ArFund;
import com.zhiche.lisa.bms.dao.model.bill.BillIoDetail;
import com.zhiche.lisa.bms.dao.model.fee.FeeAssessment;
import com.zhiche.lisa.bms.dao.model.fee.FeePayable;
import com.zhiche.lisa.bms.dao.model.fee.FeeReceivable;
import com.zhiche.lisa.bms.dao.model.fee.FeeReward;
import com.zhiche.lisa.bms.dao.model.pay.PayApply;
import com.zhiche.lisa.bms.dao.model.prepay.PrepayBill;
import com.zhiche.lisa.bms.dao.model.price.PriceIncoming;
import com.zhiche.lisa.bms.dao.model.price.PricePurchase;
import com.zhiche.lisa.bms.dao.model.quote.QuoteDtl;
import com.zhiche.lisa.bms.dao.model.sta.StaPrice;
import com.zhiche.lisa.bms.pojo.dto.driver.DriverDTO;
import com.zhiche.lisa.bms.pojo.dto.util.LspFleetDTO;
import com.zhiche.lisa.bms.pojo.dto.util.LspInfoDTO;
import com.zhiche.lisa.bms.pojo.vo.bill.BillFeeDetailVO;
import com.zhiche.lisa.bms.pojo.vo.bill.BillVO;
import com.zhiche.lisa.bms.pojo.vo.common.CommonVO;
import com.zhiche.lisa.bms.pojo.vo.fee.*;
import com.zhiche.lisa.bms.pojo.vo.invoice.InvoiceApplyExcelVO;
import com.zhiche.lisa.bms.pojo.vo.pay.PayApplyExpandVO;
import com.zhiche.lisa.bms.pojo.vo.pay.PayApplyTransformVO;
import com.zhiche.lisa.bms.pojo.vo.prepay.PrepayBillPertrolVO;
import com.zhiche.lisa.bms.pojo.vo.prepay.PrepayBillVO;
import com.zhiche.lisa.bms.pojo.vo.psup.*;
import com.zhiche.lisa.bms.pojo.vo.quote.QuoteExpandVO;
import com.zhiche.lisa.bms.pojo.vo.sta.StaPriceVO;
import com.zhiche.lisa.bms.service.utils.common.ExcelCommon;
import com.zhiche.lisa.bms.service.utils.common.ExcelUtil;
import com.zhiche.lisa.bms.service.utils.common.ImportUtil;
import com.zhiche.lisa.bms.utils.ToolCommonUtils;
import com.zhiche.lisa.core.enums.CommonEnum;
import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.core.supports.RestfulResponse;
import com.zhiche.lisa.core.utils.Account.AccountUtil;
import com.zhiche.lisa.core.utils.Account.JwtAccountVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * <p>
 * excel 相关接口
 * </p>
 *
 * @author liuanshun
 * @since 2018-08-29
 */
@RestController
@RequestMapping("/excel")
@Api(value = "/excel", description = "EXCEL导出", tags = {"导出接口"})
public class ExcelController extends BaseExcelController {
    private static final Logger LOGGER = LoggerFactory.getLogger(ExcelController.class);

    @Autowired
    private ExcelControllerMapCommon excelControllerMapCommon;


    /**
     * 下载资源
     *
     * @param key      资源key
     * @param response 自动注入结果对象
     * @return 下载资源流
     * @throws IOException
     */
    @ApiOperation(value = "导出资源账单", notes = "导出资源账单", httpMethod = "GET")
    @GetMapping("/exportResource")
    public RestfulResponse<String> exportResouce(@RequestParam String key, HttpServletResponse response) throws IOException {
        if (Strings.isNullOrEmpty(key)) {
            return new RestfulResponse<>(CommonEnum.ERROR.getCode(), "文件key接收异常", null);
        }
        RestfulResponse<String> restful = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        //获取缓冲区数据资源
        HSSFWorkbook excel = RESOURCES.get(key);
        if (Objects.isNull(excel)) {
            //未获取到资源抛出提示
            restful = new RestfulResponse<>(CommonEnum.ERROR.getCode(), "资源文件不存在", null);
        } else {
            String fileName = "excelData_" + new DateTime().toString(ToolCommonUtils.yyyyMMddHHmm);
            //通过key传值类型标识返回文件名
            String[] keySplit = key.split("_");
            if (keySplit.length > 0) {
                String fileType = keySplit[keySplit.length - 1];
                if (!StringUtils.isEmpty(fileType)) {
                    if (fileType.contains("模板")) {
                        fileName = fileType;
                    } else {
                        fileName = fileType + "_" + new DateTime().toString(ToolCommonUtils.yyyyMMddHHmm);
                    }
                }
                fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
                // //获取最后一部分
                // String fileType = excelFileNameMapping.get(keySplit[keySplit.length - 1]);
                // if (org.apache.commons.lang3.StringUtils.isNotBlank(fileType)) {
                //     fileName = fileType + new DateTime().toString(ToolCommonUtils.yyyyMMddHHmm);
                //     fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
                // }
            }
            RESOURCES.remove(key);
            LOGGER.info("DownloaExlFile: {}", key);
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xls");
            OutputStream ouputStream = response.getOutputStream();
            excel.write(ouputStream);
            ouputStream.flush();
            ouputStream.close();
        }
        return restful;
    }

    // /*
    //  * 返回文件名映射
    //  */
    // private Map<String, String> excelFileNameMapping = Maps.newHashMap();
    //
    // {
    //     excelFileNameMapping.put("FT1", "orderIncomePrice_");
    //     excelFileNameMapping.put("FT2", "orderPayPrice_");
    //     excelFileNameMapping.put("FT3", "shouldReceiptBill_");
    //     excelFileNameMapping.put("FT4", "应付账款信息_");
    //     excelFileNameMapping.put("FT5", "payApply_");
    //     excelFileNameMapping.put("FT6", "quoteExcel_");
    //     excelFileNameMapping.put("FT7", "支付申请单明细数据_");
    //     excelFileNameMapping.put("FT8", "标准价_");
    //     excelFileNameMapping.put("FT9", "第一桶油充值_");
    //     excelFileNameMapping.put("FT10", "报价单明细_");
    //     excelFileNameMapping.put("FT11", "支付申请单_");
    //     excelFileNameMapping.put("FT12", "考核单模板_");
    // }

    /**
     * importFeeAssessment
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "支付价格导出", notes = "支付价格导出", httpMethod = "POST")
    @PostMapping("/getPricePurchaseExcel")
    public RestfulResponse<String> getPricePurchaseExcel(@RequestBody Map<String, Object> condition) {
        Map<String, Object> pricePurchaseMapping = excelControllerMapCommon.getPricePurchaseMapping();
        List<String> mapVal = ExcelCommon.getMapVal(pricePurchaseMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 查询导出数据
        List<PricePurchase> list = pricePurchaseService.queryPurchaseList(condition);
        // 导出 - FT2
        return commonExportExcelResult("支付价格信息", titles, list, pricePurchaseMapping, "_支付价格信息导出");
    }

    /**
     * 获取excel收入价格数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "收入价格导出", notes = "收入价格导出", httpMethod = "POST")
    @PostMapping("/exportPriceIncoming")
    public RestfulResponse<String> exportPriceIncoming(@RequestBody Map<String, Object> condition) {
        Map<String, Object> priceIncomingMapping = excelControllerMapCommon.getPriceIncomingMapping();
        List<String> mapVal = ExcelCommon.getMapVal(priceIncomingMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 查询导出数据
        List<PriceIncoming> list = priceIncomingService.queryPricePurchaseList(condition);
        // 导出 - FT1
        return commonExportExcelResult("收入价格信息", titles, list, priceIncomingMapping, "_收入价格信息导出");
    }


    /**
     * 获取excel应收账单数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "应收账单导出", notes = "应收账单导出", httpMethod = "POST")
    @PostMapping("/exportBillIncoming")
    public RestfulResponse<String> exportBillIncoming(@RequestBody Map<String, Object> condition) {
        Map<String, Object> billIncomingMapping = excelControllerMapCommon.getBillIncomingMapping();
        List<String> mapVal = ExcelCommon.getMapVal(billIncomingMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 查询导出数据
        List<BillVO> list = billService.selectIncomingList(condition);
        // 导出_FT3
        return commonExportExcelResult("应收账单信息", titles, list, billIncomingMapping, "_应收账单信息导出");
    }

    /**
     * 获取excel应收账单详明数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "应收账单详明导出", notes = "应收账单详明导出", httpMethod = "POST")
    @PostMapping("/exportBillIncomingItem")
    public RestfulResponse<String> exportBillIncomingItem(@RequestBody Map<String, Object> condition) {
        Map<String, Object> billIncomingItemMapping = excelControllerMapCommon.getBillIncomingItemMapping();
        List<String> mapVal = ExcelCommon.getMapVal(billIncomingItemMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 查询导出数据
        Object id = condition.get("id");
        List<FeeReceivable> list = new ArrayList<>();
        if (Objects.nonNull(id)) {
            BillFeeDetailVO billIdToAnBilldFee = billService.getBillIdToAnBilldFee(id.toString());
            if (Objects.nonNull(billIdToAnBilldFee)) {
                list = billIdToAnBilldFee.getFeeReceivableList();
            }
        }
        // 导出_FT3
        return commonExportExcelResult("应收账单明细信息", titles, list, billIncomingItemMapping, "_应收账单明细信息导出");
    }

    /**
     * 获取excel应付账单数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "应付账单导出", notes = "应付账单导出", httpMethod = "POST")
    @PostMapping("/exportBillPurchase")
    public RestfulResponse<String> exportBillPurchase(@RequestBody Map<String, Object> condition) {
        Map<String, Object> billPurchaseMapping = excelControllerMapCommon.getBillPurchaseMapping();
        List<String> mapVal = ExcelCommon.getMapVal(billPurchaseMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 查询导出数据
        List<BillVO> list = billService.selectPurchaseList(condition);
        // 导出_FT4
        return commonExportExcelResult("应付账单信息", titles, list, billPurchaseMapping, "_应付账单信息导出");
    }


    /**
     * 获取excel应收账单详明数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "应付账单详明导出", notes = "应付账单详明导出", httpMethod = "POST")
    @PostMapping("/exportBillPurchaseItem")
    public RestfulResponse<String> exportBillPurchaseItem(@RequestBody Map<String, Object> condition) {
        Map<String, Object> billPurchaseItemMapping = excelControllerMapCommon.getBillPurchaseItemMapping();
        List<String> mapVal = ExcelCommon.getMapVal(billPurchaseItemMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);

        boolean areHuiYunCar = false;
        // 查询导出数据
        Object id = condition.get("id");
        List<FeePayableVO> list = new ArrayList<>();

        Map<String, Object> billPurchaseForHuiYunCarItemMapping = excelControllerMapCommon.getBillPurchaseForHuiYunCarItemMapping();
        if (Objects.nonNull(id)) {
            BillFeeDetailVO billIdToAnBilldFee = billService.getBillIdToAnBilldFee(id.toString());
            if (Objects.nonNull(billIdToAnBilldFee)) {
                if (Strings.nullToEmpty(billIdToAnBilldFee.getPayeeName()).contains("慧运车人送")) {
                    areHuiYunCar = true;
                    mapVal = ExcelCommon.getMapVal(billPurchaseForHuiYunCarItemMapping);
                    titles = mapVal.toArray(new String[mapVal.size()]);
                }

                List<FeePayableVO> feePayablesList = billIdToAnBilldFee.getFeePayablesList();
                if (areHuiYunCar) {
                    feePayablesList = pricePurchaseService.getHunyuncheInfo(feePayablesList);
                }
                if (!CollectionUtils.isEmpty(feePayablesList)) {
                    feePayablesList.forEach(feePayableVO -> {
                        //if (feePayableVO.getStartCity() != null) {
                        //	feePayableVO.setStartAddr(feePayableVO.getStartCity() +
                        //			(feePayableVO.getStartAddr() == null ? "" : feePayableVO.getStartAddr())
                        //	);
                        //}
                        feePayableVO.setStartAddr(
                                (feePayableVO.getStartProvince() == null ? "" : feePayableVO.getStartProvince())
                                        + (feePayableVO.getStartCity() == null ? "" : feePayableVO.getStartCity())
                                        + (feePayableVO.getStartCounty() == null ? "" : feePayableVO.getStartCounty())
                        );
                        feePayableVO.setEndAddr(
                                (feePayableVO.getEndProvince() == null ? "" : feePayableVO.getEndProvince())
                                        + (feePayableVO.getEndCity() == null ? "" : feePayableVO.getEndCity())
                                        + (feePayableVO.getEndCounty() == null ? "" : feePayableVO.getEndCounty())
                        );
                        list.add(feePayableVO);
                    });
                }
            }
        }
        // 导出
        // HSSFWorkbook excel = areHuiYunCar ?
        //         ExcelUtil.export("应付账单明细信息", titles, list, billPurchaseForHuiYunCarItemMapping) :
        //         ExcelUtil.export("应付账单明细信息", titles, list, billPurchaseItemMapping);
        // String key = MD5Util.backMD5(excel.toString());
        // key += "_FT4";
        // RESOURCES.put(key, excel);
        // _FT4
        if (areHuiYunCar) {
            return commonExportExcelResult("应付账单明细信息", titles, list, billPurchaseForHuiYunCarItemMapping, "_应付账单明细信息导出");
        } else {
            return commonExportExcelResult("应付账单明细信息", titles, list, billPurchaseItemMapping, "_应付账单明细信息导出");
        }
    }

    /**
     * 获取excel客户账单数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "客户账单导出", notes = "客户账单导出", httpMethod = "POST")
    @PostMapping("/exportBillIoDetail")
    public RestfulResponse<String> exportBillIoDetail(@RequestBody Map<String, Object> condition) {
        Long billId = Long.valueOf(condition.get("billId").toString());
        Map<String, Object> customentBillMapping = excelControllerMapCommon.getCustomentBillMapping();
        Map<String, Object> splitMapping = excelControllerMapCommon.getSplitMapping();
        List<String> mapVal = ExcelCommon.getMapVal(customentBillMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);

        List<BillIoDetail> billIoDetails = billIoDetailService.queryBillIoDetailList(billId);

        // 导出
        return commonExportExcelResult("客户账单详明信息", titles, billIoDetails, splitMapping, "_客户账单明细信息导出");
    }

    /**
     * 应付对账账单导出
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "应付对账账单导出", notes = "应付对账账单导出", httpMethod = "POST")
    @PostMapping("/exportPayableBillDetail")
    public RestfulResponse<String> exportPayableBillDetail(@RequestBody Map<String, Object> condition) {
        Map<String, Object> customentPayableBillMapping = excelControllerMapCommon.getCustomentPayableBillMapping();
        List<String> mapVal = ExcelCommon.getMapVal(customentPayableBillMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        HashMap<String, Object> stringObjectHashMap = new HashMap<>(customentPayableBillMapping);
        stringObjectHashMap.remove("actualPrice");
        stringObjectHashMap.remove("kilometre");

        BillFeeDetailVO billIdToAnBilldFee;
        List<FeePayableVO> feePayables = new ArrayList<>();
        Object id = condition.get("id");
        if (id != null) {
            billIdToAnBilldFee = billService.getBillIdToAnBilldFee(id.toString());
            if (billIdToAnBilldFee != null && !CollectionUtils.isEmpty(billIdToAnBilldFee.getFeePayablesList())) {
                feePayables = billIdToAnBilldFee.getFeePayablesList();
            }
        }
        // 导出_FT6
        return commonExportExcelResult("承运商账单详明导出", titles, feePayables, stringObjectHashMap, "_承运商账单明细信息导出");
    }


    /**
     * 获取excel承运商账单数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "报价单明细导出", notes = "报价单明细导出", httpMethod = "POST")
    @PostMapping("/exportQuoteDtl")
    public RestfulResponse<String> exportQuoteDtl(@RequestBody Map<String, Object> condition) {
        Map<String, Object> quoteDtlMapping = excelControllerMapCommon.getQuoteDtlMapping();
        List<String> mapVal = ExcelCommon.getMapVal(quoteDtlMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 导出_FT6
        return commonExportExcelResult("报价单明细导出", titles, Lists.newArrayList(), quoteDtlMapping, "_报价单明细信息导出");
    }


    /**
     * 获取excel承运商账单数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "应付账款导出", notes = "应付账款导出", httpMethod = "POST")
    @PostMapping("/exportFeePayable")
    public RestfulResponse<String> exportFeePayable(@RequestBody Map<String, Object> condition) {
        Map<String, Object> feePayableMapping = excelControllerMapCommon.getFeePayableMapping();
        List<String> mapVal = ExcelCommon.getMapVal(feePayableMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<FeePayable> feePayables = feePayableService.selectFeePayableList(condition);
        List<FeePayableDTO> dtoList = Lists.newArrayList();
        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(feePayables)) {
            feePayables.forEach(feePayable -> {
                if ("10".equals(feePayable.getLoadStatus())) {
                    feePayable.setLoadStatus("已发运");
                } else if ("20".equals(feePayable.getLoadStatus())) {
                    feePayable.setLoadStatus("已回单");
                } else if ("30".equals(feePayable.getLoadStatus())) {
                    feePayable.setLoadStatus("已运抵");
                }
                FeePayableDTO dto = new FeePayableDTO();
                BeanUtils.copyProperties(feePayable, dto);
                if (Integer.valueOf(0).equals(dto.getSourceSys())) {
                    dto.setSourceSysStr("系统");
                } else if (Integer.valueOf(1).equals(dto.getSourceSys())) {
                    dto.setSourceSysStr("来源");
                }
                // 是否支付申请
                if (Objects.nonNull(feePayable.getIsPay())) {
                    if (Integer.valueOf(0).equals(feePayable.getIsPay())) {
                        dto.setIsPayStr("否");
                    } else if (Integer.valueOf(1).equals(feePayable.getIsPay())) {
                        dto.setIsPayStr("是");
                    }
                } else {
                    dto.setIsPayStr("否");
                }
                // 是否排款
                if (Objects.nonNull(feePayable.getIsArrPay())) {
                    if (Integer.valueOf(0).equals(feePayable.getIsArrPay())) {
                        dto.setIsArrPayStr("否");
                    } else if (Integer.valueOf(1).equals(feePayable.getIsArrPay())) {
                        dto.setIsArrPayStr("部分");
                    } else if (Integer.valueOf(2).equals(feePayable.getIsArrPay())) {
                        dto.setIsArrPayStr("全部");
                    }
                } else {
                    dto.setIsArrPayStr("否");
                }
                // 是否付款
                if (Objects.nonNull(feePayable.getIsPayment())) {
                    if (Integer.valueOf(0).equals(feePayable.getIsPayment())) {
                        dto.setIsPaymentStr("否");
                    } else if (Integer.valueOf(1).equals(feePayable.getIsPayment())) {
                        dto.setIsPaymentStr("部分");
                    } else if (Integer.valueOf(2).equals(feePayable.getIsPayment())) {
                        dto.setIsPaymentStr("全部");
                    }
                } else {
                    dto.setIsPaymentStr("否");
                }
                dtoList.add(dto);
            });
        }
        // 导出
        return commonExportExcelResult("应付订单导出", titles, dtoList, feePayableMapping, "_应付订单信息导出");
    }

    /**
     * 获取excel承运商账单数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "预付账单导出", notes = "预付账单导出", httpMethod = "POST")
    @PostMapping("/exportPrepayBill")
    public RestfulResponse<String> exportPrepayBill(@RequestBody Map<String, Object> condition) {
        Map<String, Object> prepayBillMapping = excelControllerMapCommon.getPrepayBillMapping();
        List<String> mapVal = ExcelCommon.getMapVal(prepayBillMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<PrepayBill> prepayBills = prepayBillService.queryPrepayBillList(condition);
        // 导出
        return commonExportExcelResult("预付账单", titles, prepayBills, prepayBillMapping, "_预付账单信息导出");
    }

    /**
     * 获取excel承运商账单数据
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "奖励费用导出", notes = "奖励费用导出", httpMethod = "POST")
    @PostMapping("/exportFeeReward")
    public RestfulResponse<String> exportFeeReward(@RequestBody(required = false) Map<String, Object> condition) {
        // 导出
        if (condition != null) {
            // 导出数据
            Map<String, Object> feeRewardDateMapping = excelControllerMapCommon.getFeeRewardDateMapping();
            List<String> templateMapVal = ExcelCommon.getMapVal(feeRewardDateMapping);
            String[] templateTitles = templateMapVal.toArray(new String[templateMapVal.size()]);

            List<FeeRewardConventVO> feeRewardConventVOS = new ArrayList<FeeRewardConventVO>();
            List<FeeReward> feeRewards = feeRewardService.selectFeeRewardList(condition);
            for (FeeReward feeReward : feeRewards) {
                FeeRewardConventVO feeRewardConventVO = new FeeRewardConventVO();
                BeanUtils.copyProperties(feeReward, feeRewardConventVO);
                if (Objects.nonNull(feeReward.getCloseFlag())) {
                    if (Integer.valueOf(0).equals(feeReward.getCloseFlag())) {
                        feeRewardConventVO.setCloseFlagStr("未关闭");
                    } else if (Integer.valueOf(1).equals(feeReward.getCloseFlag())) {
                        feeRewardConventVO.setCloseFlagStr("已关闭");
                    } else {
                        feeRewardConventVO.setCloseFlagStr("未关闭");
                    }
                }
                feeRewardConventVOS.add(feeRewardConventVO);
            }
            return commonExportExcelResult("奖励费用数据导出", templateTitles, feeRewardConventVOS, feeRewardDateMapping, "_奖励费用数据导出");
        } else {
            // 下载模板
            Map<String, Object> feeRewardTemplateMapping = excelControllerMapCommon.getFeeRewardTemplateMapping();
            feeRewardTemplateMapping.remove("redCode");
            List<String> dateMapVal = ExcelCommon.getMapVal(feeRewardTemplateMapping);
            String[] dateTitles = dateMapVal.toArray(new String[dateMapVal.size()]);
            return commonExportExcelResult("奖励费用模板", dateTitles, null, feeRewardTemplateMapping, "_奖励费用模板");
        }
    }

    /**
     * 导入应付补贴
     *
     * @param data
     * @return
     */
    @PostMapping("/importFeeReward")
    @ResponseBody
    public RestfulResponse<Map<String, String>> importFeeReward(@RequestBody String data) {
        LOGGER.info("ExcelController.importFeeReward（） params : {} ", data);
        RestfulResponse<Map<String, String>> restVO = null;
        try {
            if (StringUtils.isEmpty(data)) {
                return null;
            }
            Map<String, Object> feeRewardTemplateMapping = excelControllerMapCommon.getFeeRewardTemplateMapping();
            feeRewardTemplateMapping.remove("redCode");
            data = data.trim().replace(" ", "");
            ImportUtil<FeeRewardConventVO> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            Map<String, String> msgdata = importUtil.importToData(FeeRewardConventVO.class, data, feeRewardTemplateMapping);
            //将数据导入数据库
            ArrayList<FeeReward> feeRewards = new ArrayList<>();
            ArrayList<String> feeRewardRedCodes = new ArrayList<>();
            JwtAccountVO jwtAccountVO = AccountUtil.getAccountInfoFromSecurityContext();
            for (FeeRewardConventVO feeRewardConventVO : importUtil.getDataEntity()) {
                FeeReward feeReward = new FeeReward();
                BeanUtils.copyProperties(feeRewardConventVO, feeReward);
                feeRewards.add(feeReward);
                feeReward.setRedCode(codeUtil.getRewartCode().getNextCode(null));
                feeReward.setCreateUsername(jwtAccountVO.getUsername());
                feeRewardRedCodes.add(feeReward.getRedCode());
            }
            //根据code查找是否存在
            HashMap<String, Object> existCondition = new HashMap<>();
            existCondition.put("redCodes", feeRewardRedCodes);
            List<FeeReward> existFeeReward = feeRewardService.selectFeeRewardList(existCondition);
            if (!CollectionUtils.isEmpty(existFeeReward)) {
                ArrayList<String> existMessage = new ArrayList<>();
                existFeeReward.forEach(feeReward -> existMessage.add("奖赏项编码已存在::" + feeReward.getRedCode()));
                LOGGER.error("ExcelController.importFeeReward ERROR Message : {} ", "Code Exist");
                return new RestfulResponse(CommonEnum.ERRORLIST.getCode(), "Code重复", null);
            }

            feeRewardService.insertBatchFeeReward(feeRewards);
            restVO = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), msgdata);
        } catch (Exception e) {
            LOGGER.error("ExcelController.importFeeReward ERROR Message : {} ", e);
            restVO = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return restVO;
    }

    /**
     * 导入支付价格
     *
     * @param data
     * @return
     */
    @PostMapping("/importPricePurchase")
    @ResponseBody
    public RestfulResponse<Map<String, String>> importPricePurchaseExcel(@RequestBody String data) {
        LOGGER.info("ExcelController.importPricePurchaseExcel（导入订单信息） params : {} ", data);
        RestfulResponse<Map<String, String>> restVO = null;
        try {
            if (StringUtils.isEmpty(data)) {
                return null;
            }
            ImportUtil<PricePurchase> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //移除标准价和溢价比的修改权限
            Map<String, Object> importUpdateMapping = Maps.newHashMap();
            importUpdateMapping.put("shipTaskCode", "运输任务编号");
            importUpdateMapping.put("itemUid", "货物唯一编号");
            importUpdateMapping.put("actPurchasePrice", "支付实际价格");
            //将信息导成实体
            Map<String, String> msgdata = importUtil.importToData(PricePurchase.class, data, importUpdateMapping);
            //附加执行信息
            JSONArray arrayHeader = JSONObject.parseArray(msgdata.get("header"));
            JSONArray arrayRows = JSONObject.parseArray(msgdata.get("rows"));
            arrayHeader.add("执行信息");
            //将数据导入数据库
            for (int i = 0; i < importUtil.getDataEntity().size(); i++) {
                try {
                    pricePurchaseService.updatePurchaseExlByShipTask(importUtil.getDataEntity().get(i));
                    arrayRows.getJSONObject(i).put("导入结果", "成功");
                    arrayRows.getJSONObject(i).put("执行信息", "成功！");
                } catch (Exception e) {
                    LOGGER.error("ExcelController.importPricePurchaseExcel ERROR Message : {} ", e);
                    arrayRows.getJSONObject(i).put("导入结果", "失败");
                    arrayRows.getJSONObject(i).put("执行信息", e.getMessage());
                }
            }
            //返回操作结果
            Map<String, String> map = new HashMap<>();
            map.put("header", JSONArray.toJSONString(arrayHeader));
            map.put("rows", JSONArray.toJSONString(arrayRows));
            restVO = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), map);
        } catch (Exception e) {
            LOGGER.error("ExcelController.queryPage ERROR Message : {} ", e);
            restVO = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return restVO;
    }

    /**
     * 导入客户账单
     *
     * @param data
     * @return
     */
    @PostMapping("/importCustomentBillExcel")
    @ResponseBody
    public RestfulResponse<Map<String, String>> importCustomentBillExcel(@RequestBody String data) {
        LOGGER.info("ExcelController.importCustomentBillExcel（导入客户账单） params : {} ", data);
        RestfulResponse<Map<String, String>> restVO = null;
        try {
            if (StringUtils.isEmpty(data)) {
                return null;
            }
            Map<String, Object> customentBillMapping = excelControllerMapCommon.getCustomentBillMapping();
            ImportUtil<BillIoDetail> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            Map<String, String> msgdata = importUtil.importToData(BillIoDetail.class, data, customentBillMapping);
            Long billIoId = JSONObject.parseObject(data).getLong("billId");
            //将数据导入数据库
            billIoDetailService.insertBillIoDetail(importUtil.getDataEntity(), billIoId);
            restVO = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), msgdata);
        } catch (Exception e) {
            LOGGER.error("ExcelController.queryPage ERROR Message : {} ", e);
            restVO = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return restVO;
    }


    /**
     * 导入考核奖惩费用
     *
     * @param data
     * @return
     */
    @PostMapping(value = "/importFeeAssessment")
    @ApiOperation(value = "导入考核奖惩费用", notes = "导入考核奖惩费用", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponses({@ApiResponse(code = 0, message = "success", response = PriceIncoming.class), @ApiResponse(code = -1, message = "系统异常")})
    public RestfulResponse<Map<String, String>> importFeeAssessment(@RequestBody String data, @RequestHeader("Authorization") String token) {
        LOGGER.info("ExcelController.importFeeAssessment（导入客户账单） params : {} ", data);
        RestfulResponse<Map<String, String>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            if (StringUtils.isEmpty(data)) {
                return null;
            }
            JwtAccountVO jwtAccountVO = AccountUtil.getAccountInfoFromSecurityContext();
            if (Objects.isNull(jwtAccountVO)) {
                throw new BaseException("获取登录信息异常");
            }

            Map<String, Object> exoprtFeeAssessmentMapping = excelControllerMapCommon.getExoprtFeeAssessmentMapping();
            exoprtFeeAssessmentMapping.remove("assessCode");
            ImportUtil<FeeAssessmentVO> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //ImportUtil<FeeAssessment> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            Map<String, String> msgdata = importUtil.importToData(FeeAssessmentVO.class, data, exoprtFeeAssessmentMapping);
            //Map<String, String> msgdata = importUtil.importToData(FeeAssessment.class, data, feeAssessmentMapping);
            //车队
            List<LspFleetDTO> LspFleetDTOList = Lists.newArrayList();
            //承运商
            List<LspInfoDTO> LspInfoDTOList = Lists.newArrayList();
            //司机
            List<DriverDTO> driverDTOList = Lists.newArrayList();

            List<FeeAssessmentVO> feeAssessmentList = importUtil.getDataEntity();
            if (CollectionUtils.isEmpty(feeAssessmentList)) {
                throw new BaseException("没有导入的数据！");
            }
            feeAssessmentList.forEach(feeAssessment -> {
                //导入时间为当前时间
                feeAssessment.setGmtCreate(new Date());
                //当前登录人
                feeAssessment.setCreator(Long.valueOf(jwtAccountVO.getAccountId()));
                feeAssessment.setCreateUsername(jwtAccountVO.getUsername());
                // feeAssessment.setTenantId(Long.valueOf(jwtAccountVO.getTenantId()));
                //考核金额
                BigDecimal assessSum = Objects.nonNull(feeAssessment.getAssessSum()) ? feeAssessment.getAssessSum() : BigDecimal.ZERO;
                //减免金额
                BigDecimal mitigateSum = Objects.nonNull(feeAssessment.getMitigateSum()) ? feeAssessment.getMitigateSum() : BigDecimal.ZERO;
                //总罚金额(考核金额-减免金额)
                feeAssessment.setAmount(assessSum.subtract(mitigateSum));

                feeAssessment.setPerformSum(BigDecimal.ZERO);
                feeAssessment.setBalanceSum(feeAssessment.getAmount());
                //if(feeAssessment.getFleetTeye() == String.valueOf(LSP_INFO_NAME)){//承运商
//                if ("承运商".equals(feeAssessment.getFleetTeye())) {//承运商
                LspInfoDTO lspInfoDTO = new LspInfoDTO();
                lspInfoDTO.setName(feeAssessment.getLspName());
                LspInfoDTOList.add(lspInfoDTO);
                //feeAssessment.setLspName(String.valueOf(LSP_INFO_NAME));
//                }
                //else if (feeAssessment.getFleetTeye() == String.valueOf(LISA_FLEET_NAME)) {// 车队
                //    feeAssessment.setFleetStatus(String.valueOf(LISA_FLEET_NAME));
                //} else if (feeAssessment.getFleetTeye() == String.valueOf(LISA_DRIVER_NAME)) {// 司机
                //    feeAssessment.setFleetStatus(String.valueOf(LISA_DRIVER_NAME));
                //}

                LspFleetDTO lspFleetDTO = new LspFleetDTO();
                lspFleetDTO.setFleetName(feeAssessment.getFleetStatus());
                LspFleetDTOList.add(lspFleetDTO);

                DriverDTO driverDTO = new DriverDTO();
                driverDTO.setName(feeAssessment.getFleetStatus());
                driverDTO.setSendCarPass(feeAssessment.getSendCarPass());
                driverDTOList.add(driverDTO);
            });
            //获取承运商信息
            List<LspInfoDTO> lspInfoList = lspUtil.getLspInfoAll(LspInfoDTOList, token);
            if (!lspInfoList.isEmpty()) {
                feeAssessmentList.forEach(feeAssessment -> {
                    lspInfoList.forEach(lspInfo -> {
                        if (feeAssessment.getLspName().equals(lspInfo.getName())) {
                            feeAssessment.setLspId(lspInfo.getId());
                            feeAssessment.setTenantId(lspInfo.getTenantId());
                        }
                    });
                });
            }

            //获取车队信息
            List<LspFleetDTO> fleetList = lspUtil.getFleetAll(LspFleetDTOList, token);
            if (!fleetList.isEmpty()) {
                feeAssessmentList.forEach(feeAssessment -> {
                    fleetList.forEach(fleet -> {
                        if (feeAssessment.getFleetStatus().equals(fleet.getFleetName())) {
                            feeAssessment.setFleetId(fleet.getId());
                        }
                    });
                });
            }

            //获取司机信息
            List<DriverDTO> driverList = lspUtil.getDriverAll(driverDTOList, token);
            if (!driverList.isEmpty()) {
                feeAssessmentList.forEach(feeAssessment -> {
                    driverList.forEach(driver -> {
                        if (feeAssessment.getFleetStatus().equals(driver.getName())) {
                            feeAssessment.setFleetId(driver.getId());
                            if (StringUtils.isEmpty(feeAssessment.getSendCarPass())) {
                                feeAssessment.setSendCarPass(driver.getSendCarPass());
                            }
                            if (StringUtils.isEmpty(feeAssessment.getDriverPhone())) {
                                feeAssessment.setDriverPhone(driver.getMobile());
                            }
                        }
                    });
                });
            }

            //将数据导入数据库
            List<FeeAssessment> insertFeeAssessmentList = Lists.newArrayList();
            DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM");
            feeAssessmentList.forEach(fee -> {
                FeeAssessment insertFee = new FeeAssessment();
                BeanUtils.copyProperties(fee, insertFee);
                if ("承运商".equals(fee.getFleetTeye())) {
                    insertFee.setFleetTeye("10");
                } else if ("车队".equals(fee.getFleetTeye())) {
                    insertFee.setFleetTeye("20");
                } else if ("司机".equals(fee.getFleetTeye())) {
                    insertFee.setFleetTeye("30");
                }
                if (!StringUtils.isEmpty(fee.getInvoiceTypeName())) {
                    if ("票内".equals(fee.getInvoiceTypeName().trim())) {
                        insertFee.setInvoiceType(0);
                    } else if ("票外".equals(fee.getInvoiceTypeName().trim())) {
                        insertFee.setInvoiceType(1);
                    } else {
                        insertFee.setInvoiceType(1);
                    }
                } else {
                    insertFee.setInvoiceType(1);
                }
                if (!StringUtils.isEmpty(fee.getAssessMonthStr())) {
                    insertFee.setAssessMonth(format.parseDateTime(fee.getAssessMonthStr()).toDate());
                }
                insertFee.setAssessCode(codeUtil.getAssessmentCode().getNextCode(null));
                insertFeeAssessmentList.add(insertFee);
            });

            //feeAssessmentService.insertFeeAssessment(feeAssessmentList);
            feeAssessmentService.insertFeeAssessment(insertFeeAssessmentList);
            result.setData(msgdata);
        } catch (BaseException e) {
            LOGGER.error("/ExcelController.importFeeAssessment ERROR: {}", e.getMessage());
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("/ExcelController.importFeeAssessment ERROR: {}", e.getMessage());
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), "导入失败!", null);
        }
        return result;
    }

    /**
     * 导入应收款项
     *
     * @param data
     * @return
     */
    @PostMapping("/importArFundExcel")
    @ResponseBody
    public RestfulResponse<List<String>> importArFundExcel(@RequestBody String data) {
        LOGGER.info("ExcelController.importArFundExcel（导入应收款项） params : {} ", data);
        RestfulResponse<List<String>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), "导入成功", null);
        try {
            if (StringUtils.isEmpty(data)) {
                return null;
            }
            Map<String, Object> arFundMapping = excelControllerMapCommon.getArFundMapping();
            ImportUtil<ArFund> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            Map<String, String> msgdata = importUtil.importToData(ArFund.class, data, arFundMapping);
            //将数据导入数据库
            List<String> stringList = arFundService.insertArFund(importUtil.getDataEntity());
            if (!CollectionUtils.isEmpty(stringList)) {
                result = new RestfulResponse<>(CommonEnum.ERRORLIST.getCode(), CommonEnum.ERRORLIST.getText(), null);
                result.setData(stringList);
            }
        } catch (Exception e) {
            LOGGER.error("ExcelController.importArFundExcel ERROR Message : {} ", e);
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 导入应收款项
     *
     * @param data
     * @return
     */
    @PostMapping("/importFeePayableByOTMExcelDate")
    @ResponseBody
    public RestfulResponse<List<String>> importFeePayableByOTMExcel(@RequestBody String data) {
        LOGGER.info("ExcelController.importFeePayableByOTMExcelDate（根据otmExcel导入应付账款数据） params : {} ", data);
        RestfulResponse<List<String>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), "导入成功", null);
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
            if (StringUtils.isEmpty(data)) {
                return null;
            }
            ImportUtil<FeePayableVO> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            Map<String, Object> feePayApplyByOtmExcelMapping = excelControllerMapCommon.getFeePayApplyByOtmExcelMapping();
            Map<String, String> msgdata = importUtil.importToData(FeePayableVO.class, data, feePayApplyByOtmExcelMapping);
            //将数据导入数据库
            List<FeePayableVO> dataEntity = importUtil.getDataEntity();
            List<FeePayable> feePayables = new ArrayList<>();
            dataEntity.forEach(
                    feePayableVO -> {
                        FeePayable feePayable = new FeePayable();
                        BeanUtils.copyProperties(feePayableVO, feePayable);
                        String s = Strings.nullToEmpty(feePayableVO.getCanProvisional());
                        if (("正式").equals(s)) {
                            feePayable.setActualPrice(feePayable.getEstPrice());
                            feePayable.setOilBaPay(BigDecimal.ZERO);
                            feePayable.setActualAmt(feePayable.getEstAmt());
                            feePayable.setCashBaPay(feePayable.getEstAmt());
                        } else if ("暂估".equals(s)) {
                            feePayable.setActualPrice(BigDecimal.ZERO);
                            feePayable.setActualAmt(BigDecimal.ZERO);
                            feePayable.setCashBaPay(feePayable.getEstAmt());
                        }
                        feePayables.add(feePayable);
                    }
            );
            feePayableService.insertBatchFeePayable(feePayables);
            List<String> stringList = new ArrayList<>();
            if (!CollectionUtils.isEmpty(stringList)) {
                result = new RestfulResponse<>(CommonEnum.ERRORLIST.getCode(), CommonEnum.ERRORLIST.getText(), null);
                result.setData(stringList);
            }
        } catch (Exception e) {
            LOGGER.error("ExcelController.importFeePayableByOTMExcelDate ERROR Message : {} ", e);
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping("/importFeePayableByOTMExcel")
    @ResponseBody
    public RestfulResponse<List<String>> importFeePayableByOTMExcel(@RequestParam("file") MultipartFile file) throws IOException {
        RestfulResponse<List<String>> result = null;
        try {
            if (file == null) {
                result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), "文件不存在", null);
            }
            Workbook workBookByMultipartFile = ExcelUtil.getWorkBookByMultipartFile(file);
            if (workBookByMultipartFile == null) {
                result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), "文件不是Xls/Xlsx", null);
            }
            result = importFeePayableByOTMExcel(ExcelUtil.read(workBookByMultipartFile));
        } catch (Exception e) {
            LOGGER.error("ExcelController.importFeePayableByOTMExcel ERROR Message : {} ", e);
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /***
     * 导出考核奖惩费用
     */
    @PostMapping(value = "/exportFeeAssessment")
    @ApiOperation(value = "导出考核奖惩费用", notes = "导出考核奖惩费用", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponses({@ApiResponse(code = 0, message = "success", response = PriceIncoming.class), @ApiResponse(code = -1, message = "系统异常")})
    public RestfulResponse<String> exportFeeAssessment() {
        Map<String, Object> feeAssessmentMapping = excelControllerMapCommon.getFeeAssessmentMapping();
        feeAssessmentMapping.remove("assessCode");
        List<String> mapVal = ExcelCommon.getMapVal(feeAssessmentMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 导出
        return commonExportExcelResult("考核奖惩费用", titles, Lists.newArrayList(), feeAssessmentMapping, "_考核单模板");
    }

    /**
     * 考核单息导出
     *
     * @return
     */
    @ApiOperation(value = "考核单信息导出", notes = "考核单信息导出", httpMethod = "POST")
    @PostMapping("/importFeeAssessmentData")
    public RestfulResponse<String> importFeeAssessmentData(@RequestBody Map<String, Object> condition) {
        Map<String, Object> feeAssessmentMapping = excelControllerMapCommon.getFeeAssessExportMapping();
        List<String> mapVal = ExcelCommon.getMapVal(feeAssessmentMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 导出Excel
        List<FeeAssessmentImportVO> voList = feeAssessmentService.queryFeeAssessmentListByCondition(condition);
        return commonExportExcelResult("考核单信息导出", titles, voList, feeAssessmentMapping, "_考核单信息导出");
    }

    /**
     * 导出应收款项模板
     */
    @ApiOperation(value = "导出应收款项模板", notes = "导出应收款项模板", httpMethod = "GET")
    @GetMapping("/exportArFundExcel")
    public RestfulResponse<String> exportArFundExcel(HttpServletResponse response) throws IOException {
        Map<String, Object> arFundMapping = excelControllerMapCommon.getArFundMapping();
        List<String> mapVal = ExcelCommon.getMapVal(arFundMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 导出
        HSSFWorkbook excel = ExcelUtil.export("应收款项信息", titles, new ArrayList<>(), arFundMapping);
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-disposition", "attachment;filename=ohterBill.xls");
        OutputStream ouputStream = response.getOutputStream();
        excel.write(ouputStream);
        ouputStream.flush();
        ouputStream.close();
        return new RestfulResponse<String>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
    }

    /**
     * 支付申请单导出
     *
     * @param condition
     * @return
     */
    @ApiOperation(value = "支付申请单导出", notes = "支付申请单导出", httpMethod = "POST")
    @PostMapping("/getPaymentRequestExcel")
    public RestfulResponse<String> getPaymentRequestExcel(@RequestBody Map<String, Object> condition) {
        Map<String, Object> payApplyMapping = excelControllerMapCommon.getPayApplyMapping();
        List<String> mapVal = ExcelCommon.getMapVal(payApplyMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 查询导出数据
        List<PayApply> list = payApplyService.queryPayApplyList(condition);
        List<PayApplyTransformVO> transformVOS = new ArrayList<>();
        list.forEach(payApply -> {
            PayApplyTransformVO payApplyTransformVO = new PayApplyTransformVO();
            BeanUtils.copyProperties(payApply, payApplyTransformVO);
            transformVOS.add(payApplyTransformVO);
        });
        // 导出_FT5
        return commonExportExcelResult("支付申请单信息", titles, transformVOS, payApplyMapping, "_支付申请单信息导出");
    }

    /**
     * 支付申请单导出
     *
     * @param condition
     * @return
     */
    @ApiOperation(value = "支付申请单明细导出", notes = "支付申请单明细导出", httpMethod = "POST")
    @PostMapping("/getPaymentBillDetailListRequestExcel")
    public RestfulResponse<String> getPaymentBillDetailListRequestExcel(@RequestBody Map<String, Object> condition) {
        Map<String, Object> billPurchaseItemMapping = excelControllerMapCommon.getBillPurchaseItemMapping();
        List<String> mapVal = ExcelCommon.getMapVal(billPurchaseItemMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 查询导出数据
        Object idArray = condition.get("idArray");
        List<Long> payIdList = JSONArray.parseArray(JSONObject.toJSONString(idArray), Long.class);
        List<FeePayableVO> list = new ArrayList<>();
        if (!CollectionUtils.isEmpty(payIdList)) {
            payIdList.forEach(payId -> {
                List<Long> idList = payApplyService.getPayApplyBillDetailIdList(payId);
                PayApply payApply = payApplyService.selectById(payId);
                List<BillFeeDetailVO> billIdToAnBilldFeeList = billService.getBillIdToAnBilldFeeList(idList);

                if (!CollectionUtils.isEmpty(billIdToAnBilldFeeList)) {
                    billIdToAnBilldFeeList.forEach(billDtl -> {
                        List<FeePayableVO> feePayablesList = billDtl.getFeePayablesList();
                        if (!CollectionUtils.isEmpty(feePayablesList)) {
                            feePayablesList.forEach(feePayableVO -> {
                                if (feePayableVO.getStartCity() != null) {
                                    feePayableVO.setStartAddr(feePayableVO.getStartCity() +
                                            (feePayableVO.getStartAddr() == null ? "" : feePayableVO.getStartAddr())
                                    );
                                }
                                feePayableVO.setEndAddr(
                                        (feePayableVO.getEndProvince() == null ? "" : feePayableVO.getEndProvince())
                                                + (feePayableVO.getEndCity() == null ? "" : feePayableVO.getEndCity())
                                                + (feePayableVO.getEndCounty() == null ? "" : feePayableVO.getEndCounty())
                                );
                                // 支付申请号
                                if (payApply != null) {
                                    feePayableVO.setPayApplyCode(payApply.getPayApplyCode());
                                }
                                list.add(feePayableVO);
                            });
                        }
                    });
                }

            });
        }

        // 导出_FT7
        return commonExportExcelResult("支付申请单明细信息", titles, list, billPurchaseItemMapping, "_支付申请单明细信息导出");
    }

    /**
     * 获取excel标准价导出
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "标准价导出", notes = "标准价导出", httpMethod = "POST")
    @PostMapping("/exportStaPrice")
    public RestfulResponse<String> exportStaPrice(@RequestBody Map<String, Object> condition) {
        Map<String, Object> staPriceMapping = excelControllerMapCommon.getStaPriceMapping();
        List<String> mapVal = ExcelCommon.getMapVal(staPriceMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<StaPrice> staPriceList = staPriceService.selectStaPriceList(condition);

        List<StaPriceVO> exprotVoList = Lists.newArrayList();
        if (!CollectionUtils.isEmpty(staPriceList)) {
            staPriceList.forEach(staPrice -> {
                StaPriceVO staPriceVO = new StaPriceVO();
                BeanUtils.copyProperties(staPrice, staPriceVO);
                exprotVoList.add(staPriceVO);
            });
        }
        // 导出_FT8
        return commonExportExcelResult("标准价导出", titles, exprotVoList, staPriceMapping, "_标准价信息导出");
    }

    /**
     * 第一桶油充值预付导出
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "第一桶油充值预付导出", notes = "第一桶油充值预付导出", httpMethod = "POST")
    @PostMapping("/exportPertrolOilPrepayBill")
    public RestfulResponse<String> exportPertrolOilPrepayBill(@RequestBody Map<String, Object> condition) {
        Map<String, Object> pertrolOilPrepayBillMapping = excelControllerMapCommon.getPertrolOilPrepayBillMapping();
        List<String> mapVal = ExcelCommon.getMapVal(pertrolOilPrepayBillMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<PrepayBillPertrolVO> prepayBills = prepayBillService.queryPertrolOilPrepayBillList(condition);
        if (!CollectionUtils.isEmpty(prepayBills)) {
            prepayBills.forEach(prepayBill -> {
                if (Integer.valueOf(0).equals(prepayBill.getPertrolOilStatus())) {
                    prepayBill.setPertrolOilStatusStr("未确认");
                } else if (Integer.valueOf(1).equals(prepayBill.getPertrolOilStatus())) {
                    prepayBill.setPertrolOilStatusStr("已确认");
                }
                // 加油确认时间
                if (Objects.nonNull(prepayBill.getPertrolOilDate())) {
                    prepayBill.setPertrolOilDateStr(new DateTime(prepayBill.getPertrolOilDate()).toString(ToolCommonUtils.yyyyMMdd));
                }
            });
        }
        // 导出_FT9
        return commonExportExcelResult("第一桶油充值预付导出", titles, prepayBills, pertrolOilPrepayBillMapping, "_第一桶油充值预付信息导出");
    }

    /**
     * 报价单明细导出
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "报价单明细导出", notes = "报价单明细导出", httpMethod = "POST")
    @PostMapping("/exportQuoteDetailExpand")
    public RestfulResponse<String> exportQuoteDetailExpand(@RequestBody CommonVO<Long> voList) {
        Map<String, Object> quoteExpandExport = excelControllerMapCommon.getQuoteExpandExport();
        List<String> mapVal = ExcelCommon.getMapVal(quoteExpandExport);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<QuoteExpandVO> quoteExpandVoList = Lists.newArrayList();
        if (voList != null && !CollectionUtils.isEmpty(voList.getEntityParams())) {
            quoteExpandVoList = quoteDtlService.getQuoteExpandByQuoteIdList(voList.getEntityParams());
        }
        // 导出_FT10
        return commonExportExcelResult("报价单明细导出", titles, quoteExpandVoList, quoteExpandExport, "_报价单明细信息导出");
    }

    /**
     * 支付申请单导出
     *
     * @return 返回文件名称及excel文件的URL
     * @throws IOException
     */
    @ApiOperation(value = "支付申请单导出", notes = "支付申请单导出", httpMethod = "POST")
    @PostMapping("/exportPayApplyHead")
    public RestfulResponse<String> exportPayApplyHead(@RequestBody Map<String, Object> condition) {
        Map<String, Object> payApplyExpandMapping = excelControllerMapCommon.getPayApplyExpandMapping();
        List<String> mapVal = ExcelCommon.getMapVal(payApplyExpandMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<PayApply> payApplieList = payApplyService.queryPayApplyList(condition);
        List<PayApplyExpandVO> expandVOList = Lists.newArrayList();
        if (!CollectionUtils.isEmpty(payApplieList)) {
            payApplieList.forEach(payApply -> {
                PayApplyExpandVO expandVO = new PayApplyExpandVO();
                BeanUtils.copyProperties(payApply, expandVO);
                if (Objects.nonNull(payApply.getChargeSum()) && Objects.nonNull(payApply.getIncSum())) {
                    expandVO.setTotalChargeSum(payApply.getChargeSum().add(payApply.getIncSum()));
                }
                expandVOList.add(expandVO);
            });
        }
        // 导出
        // HSSFWorkbook excel = ExcelUtil.export("支付申请单导出", titles, expandVOList, payApplyExpandMapping);
        // return commonExportResult(excel, "_FT11");
        return commonExportExcelResult("支付申请单导出", titles, expandVOList, payApplyExpandMapping, "_支付申请单数据");
    }

    /**
     * 导出油卡预付数据
     *
     * @param condition
     * @return
     */
    @PostMapping(value = "/importPrepayBillOilPriceData")
    @ApiOperation(value = "导出油卡预付数据", notes = "导出油卡预付数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponses({@ApiResponse(code = 0, message = "success", response = PriceIncoming.class), @ApiResponse(code = -1, message = "系统异常")})
    public RestfulResponse<String> importPrepayBillOilPriceData(@RequestBody Map<String, Object> condition) {
        Map<String, Object> prepayBillOilMapping = excelControllerMapCommon.getPrepayBillOilMapping();
        List<String> mapVal = ExcelCommon.getMapVal(prepayBillOilMapping);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        String importName = "_预付数据信息导出";
        if (Objects.nonNull(condition) && Objects.nonNull(condition.get("prepayType"))) {
            Object prepayType = condition.get("prepayType");
            if ("0".equals(prepayType.toString())) {
                importName = "_油卡预付数据信息导出";
            } else if ("1".equals(prepayType.toString())) {
                importName = "_现金预付数据信息导出";
            }
        }
        // 导出
        List<PrepayBill> prepayBillList = prepayBillService.queryPrepayBillList(condition);
        List<PrepayBillVO> voList = Lists.newArrayList();
        if (!CollectionUtils.isEmpty(prepayBillList)) {
            prepayBillList.forEach(prepayBill -> {
                PrepayBillVO vo = new PrepayBillVO();
                BeanUtils.copyProperties(prepayBill, vo);
                // 0-油卡, 1-现金
                if (Integer.valueOf(0).equals(prepayBill.getPrepayType())) {
                    vo.setPrepayTypeStr("油卡");
                } else if (Integer.valueOf(1).equals(prepayBill.getPrepayType())) {
                    vo.setPrepayTypeStr("现金");
                }
                // 10-新增、20-审核、30-确认
                if (Integer.valueOf(10).equals(prepayBill.getStatus())) {
                    vo.setStatusStr("新增");
                } else if (Integer.valueOf(20).equals(prepayBill.getStatus())) {
                    vo.setStatusStr("审核");
                } else if (Integer.valueOf(30).equals(prepayBill.getStatus())) {
                    vo.setStatusStr("确认");
                }
                if (Objects.nonNull(prepayBill.getGmtCreate())) {
                    vo.setGmtCreateStr(new DateTime(prepayBill.getGmtCreate()).toString(ToolCommonUtils.yyyyMMdd));
                }
                voList.add(vo);
            });
        }
        return commonExportExcelResult(importName, titles, voList, prepayBillOilMapping, importName);
    }

    /**
     * 下载人送基础信息模板
     *
     * @return
     */
    @ApiOperation(value = "人送基础信息模板", notes = "人送基础信息模板", httpMethod = "POST")
    @PostMapping("/downloadSdBaseDataExcelTemplate")
    public RestfulResponse<String> downloadSdBaseDataExcelTemplate() {
        Map<String, Object> sdBaseDataInfoMap = excelControllerMapCommon.getSdBaseDataInfoTemplateMap(true);
        List<String> mapVal = ExcelCommon.getMapVal(sdBaseDataInfoMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<PsupBaseDataVO> voList = Lists.newArrayList();
        PsupBaseDataVO baseDataVO = new PsupBaseDataVO();
        baseDataVO.setPriorityStr("高/中/低");
        baseDataVO.setPriceModelStr("传统价格模式/人送价格模式/一口价模式");
        baseDataVO.setLinkFlagStr("是/否");
        voList.add(baseDataVO);
        // 下载Excel
        return commonExportExcelResult("人送基础信息模板", titles, voList, sdBaseDataInfoMap, "_人送基础信息模板下载");
    }

    /**
     * 导入人送基础信息
     *
     * @return
     */
    @ApiOperation(value = "导入人送基础信息", notes = "导入人送基础信息", httpMethod = "POST")
    @PostMapping("/importSdBaseDataExcel")
    public RestfulResponse<Object> importSdBaseDataExcel(@RequestBody String data, @RequestHeader("Authorization") String token) {
        LOGGER.info("ExcelController.importSdBaseDataExcel（导入人送基础信息） params : {} ", data);
        RestfulResponse<Object> resultResponse = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            // 校验-1
            if (verifyStringData(data, resultResponse)) {
                return resultResponse;
            }
            Map<String, Object> sdBaseDataInfoMap = excelControllerMapCommon.getSdBaseDataInfoTemplateMap(true);
            ImportUtil<PsupBaseDataVO> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            importUtil.importToData(PsupBaseDataVO.class, data, sdBaseDataInfoMap);
            //将数据导入数据库
            List<PsupBaseDataVO> dataEntity = importUtil.getDataEntity();
            // 校验是否有数据
            if (verifyDataEntity(dataEntity, resultResponse)) {
                return resultResponse;
            }
            // 校验是否有数据
            List<String> resultStr = psupBaseDataService.batchImportExcelData(dataEntity, token);
            if (verifyErrorList(resultStr, resultResponse)) {
                return resultResponse;
            }
        } catch (BaseException e) {
            LOGGER.error("ExcelController.importSdOilPriceExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("ExcelController.importSdOilPriceExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(CommonEnum.ERROR.getText());
        }
        return resultResponse;
    }

    /**
     * 人送基础信息导出
     *
     * @return
     */
    @ApiOperation(value = "人送基础信息导出", notes = "人送基础信息导出", httpMethod = "POST")
    @PostMapping("/exportSdBaseDataExcel")
    public RestfulResponse<String> exportSdBaseDataExcel(@RequestBody Map<String, Object> condition) {
        Map<String, Object> sdBaseDataInfoMap = excelControllerMapCommon.getSdBaseDataInfoTemplateMap(false);
        List<String> mapVal = ExcelCommon.getMapVal(sdBaseDataInfoMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<PsupBaseDataVO> voList = psupBaseDataService.querySdBaseDataInfoByCondition(condition);
        // 导出Excel
        return commonExportExcelResult("人送基础信息导出", titles, voList, sdBaseDataInfoMap, "_人送基础信息导出");
    }

    /**
     * 下载人送传统价格模板
     *
     * @return
     */
    @ApiOperation(value = "人送传统价格模板", notes = "人送传统价格模板", httpMethod = "POST")
    @PostMapping("/downloadSdTraditionPriceExcelTemplate")
    public RestfulResponse<String> downloadSdTraditionPriceExcelTemplate() {
        Map<String, Object> sdTraditionPriceMap = excelControllerMapCommon.getSdTraditionPriceExcelTemplateMap(true);
        List<String> mapVal = ExcelCommon.getMapVal(sdTraditionPriceMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 下载Excel
        return commonExportExcelResult("人送传统价格模板", titles, null, sdTraditionPriceMap, "_人送传统价格模板下载");
    }

    /**
     * 导入人送传统价格
     *
     * @return
     */
    @ApiOperation(value = "导入人送传统价格", notes = "导入人送传统价格", httpMethod = "POST")
    @PostMapping("/importSdTraditionPriceExcel")
    public RestfulResponse<Object> importSdTraditionPriceExcel(@RequestBody String data, @RequestHeader("Authorization") String token) {
        LOGGER.info("ExcelController.importSdTraditionPriceExcel（导入人送传统价格） params : {} ", data);
        RestfulResponse<Object> resultResponse = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            // 校验-1
            if (verifyStringData(data, resultResponse)) {
                return resultResponse;
            }
            Map<String, Object> sdTraditionPriceMap = excelControllerMapCommon.getSdTraditionPriceExcelTemplateMap(true);
            ImportUtil<PsupTraditionPriceVO> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            importUtil.importToData(PsupTraditionPriceVO.class, data, sdTraditionPriceMap);
            //将数据导入数据库
            List<PsupTraditionPriceVO> dataEntity = importUtil.getDataEntity();

            // 校验是否有数据
            if (verifyDataEntity(dataEntity, resultResponse)) {
                return resultResponse;
            }
            // 校验是否有数据
            List<String> resultStr = psupTraditionPriceService.createBatchTraditionPriceForExcel(dataEntity, token);
            if (verifyErrorList(resultStr, resultResponse)) {
                return resultResponse;
            }
        } catch (BaseException e) {
            LOGGER.error("ExcelController.importSdTraditionPriceExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("ExcelController.importSdTraditionPriceExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(CommonEnum.ERROR.getText());
        }
        return resultResponse;
    }

    /**
     * 人送传统价格数据导出
     *
     * @return
     */
    @ApiOperation(value = "人送传统价格数据导出", notes = "人送基础信息导出", httpMethod = "POST")
    @PostMapping("/exportSdTraditionPriceExcel")
    public RestfulResponse<String> exportSdTraditionPriceExcel(@RequestBody Map<String, Object> condition) {
        Map<String, Object> sdTraditionPriceMap = excelControllerMapCommon.getSdTraditionPriceExcelTemplateMap(false);
        List<String> mapVal = ExcelCommon.getMapVal(sdTraditionPriceMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<PsupTraditionPriceVO> voList = psupTraditionPriceService.querySdTraditionPriceByCondition(condition);
        // 导出Excel
        return commonExportExcelResult("人送传统价格数据导出", titles, voList, sdTraditionPriceMap, "_人送传统价格数据导出");
    }

    /**
     * 下载人送一口价模板
     *
     * @return
     */
    @ApiOperation(value = "人送传统价格模板", notes = "人送传统价格模板", httpMethod = "POST")
    @PostMapping("/downloadSdFixedPriceExcelTemplate")
    public RestfulResponse<String> downloadSdFixedPriceExcelTemplate() {
        Map<String, Object> sdFixedPriceTemplateMap = excelControllerMapCommon.getSdFixedPriceExcelTemplateMap(true);
        List<String> mapVal = ExcelCommon.getMapVal(sdFixedPriceTemplateMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 下载Excel
        return commonExportExcelResult("人送一口价模板", titles, null, sdFixedPriceTemplateMap, "_人送一口价模板下载");
    }

    /**
     * 导入人送一口价
     *
     * @return
     */
    @ApiOperation(value = "导入人送一口价", notes = "导入人送一口价", httpMethod = "POST")
    @PostMapping("/importSdFixedPriceExcel")
    public RestfulResponse<Object> importSdFixedPricePriceExcel(@RequestBody String data, @RequestHeader("Authorization") String token) {
        LOGGER.info("ExcelController.importSdFixedPricePriceExcel（导入人送一口价） params : {} ", data);
        RestfulResponse<Object> resultResponse = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            // 校验-1
            if (verifyStringData(data, resultResponse)) {
                return resultResponse;
            }
            Map<String, Object> sdFixedPriceExcelTemplateMap = excelControllerMapCommon.getSdFixedPriceExcelTemplateMap(true);
            ImportUtil<PsupFixedPriceVO> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            importUtil.importToData(PsupFixedPriceVO.class, data, sdFixedPriceExcelTemplateMap);
            //将数据导入数据库
            List<PsupFixedPriceVO> dataEntity = importUtil.getDataEntity();

            // 校验是否有数据
            if (verifyDataEntity(dataEntity, resultResponse)) {
                return resultResponse;
            }
            // 校验是否有数据
            List<String> resultStr = psupFixedPriceService.createBatchFixedPriceForExcel(dataEntity, token);
            if (verifyErrorList(resultStr, resultResponse)) {
                return resultResponse;
            }
        } catch (BaseException e) {
            LOGGER.error("ExcelController.importSdFixedPricePriceExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("ExcelController.importSdFixedPricePriceExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(CommonEnum.ERROR.getText());
        }
        return resultResponse;
    }

    /**
     * 人送一口价数据导出
     *
     * @return
     */
    @ApiOperation(value = "人送传统价格数据导出", notes = "人送基础信息导出", httpMethod = "POST")
    @PostMapping("/exportSdFixedPriceExcel")
    public RestfulResponse<String> exportSdFixedPriceExcel(@RequestBody Map<String, Object> condition) {
        Map<String, Object> sdFixedPriceExcelTemplateMap = excelControllerMapCommon.getSdFixedPriceExcelTemplateMap(false);
        List<String> mapVal = ExcelCommon.getMapVal(sdFixedPriceExcelTemplateMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<PsupFixedPriceVO> voList = psupFixedPriceService.queryFixedPriceListByCondition(condition);
        // 导出Excel
        return commonExportExcelResult("人送一口价数据导出", titles, voList, sdFixedPriceExcelTemplateMap, "_人送一口价数据导出");
    }

    /**
     * 下载人送车型对照模板
     *
     * @return
     */
    @ApiOperation(value = "下载人送车型对照模板", notes = "下载人送车型对照模板", httpMethod = "POST")
    @PostMapping("/downloadSdVehicleContrastExcelTemplate")
    public RestfulResponse<String> downloadSdVehicleContrastExcelTemplate() {
        Map<String, Object> sdVehicleContrastMap = excelControllerMapCommon.getSdSdVehicleContrastTemplateMap();
        List<String> mapVal = ExcelCommon.getMapVal(sdVehicleContrastMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 下载Excel
        return commonExportExcelResult("人送车型对照模板", titles, null, sdVehicleContrastMap, "_人送车型对照模板下载");
    }

    /**
     * 导入人送车型对照
     *
     * @return
     */
    @ApiOperation(value = "导入人送车型对照", notes = "导入人送车型对照", httpMethod = "POST")
    @PostMapping("/importSdVehicleContrastExcel")
    public RestfulResponse<Object> importSdVehicleContrastExcel(@RequestBody String data) {
        LOGGER.info("ExcelController.importSdFixedPricePriceExcel（导入人送车型对照） params : {} ", data);
        RestfulResponse<Object> resultResponse = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            // 校验-1
            if (verifyStringData(data, resultResponse)) {
                return resultResponse;
            }
            Map<String, Object> sdVehicleContrastMap = excelControllerMapCommon.getSdSdVehicleContrastTemplateMap();
            ImportUtil<PsupVehicleContrastVO> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            importUtil.importToData(PsupVehicleContrastVO.class, data, sdVehicleContrastMap);
            //将数据导入数据库
            List<PsupVehicleContrastVO> dataEntity = importUtil.getDataEntity();

            // 校验是否有数据
            if (verifyDataEntity(dataEntity, resultResponse)) {
                return resultResponse;
            }
            // 校验是否有数据
            psupVehicleContrastService.insertBatchSdVehicleContrast(dataEntity);
        } catch (BaseException e) {
            LOGGER.error("ExcelController.importSdVehicleContrastExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("ExcelController.importSdVehicleContrastExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(CommonEnum.ERROR.getText());
        }
        return resultResponse;
    }

    /**
     * 下载人送其他费用模板
     *
     * @return
     */
    @ApiOperation(value = "下载人送其他费用模板", notes = "下载人送其他费用模板", httpMethod = "POST")
    @PostMapping("/downloadSdOtherExpensisesExcelTemplate")
    public RestfulResponse<String> downloadSdOtherExpensisesExcelTemplate() {
        Map<String, Object> sdOtherExpensisesTmplateMap = excelControllerMapCommon.getSdOtherExpensisesTmplateMap(true);
        List<String> mapVal = ExcelCommon.getMapVal(sdOtherExpensisesTmplateMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 下载Excel
        return commonExportExcelResult("人送其他费用模板", titles, null, sdOtherExpensisesTmplateMap, "_人送其他费用模板下载");
    }

    /**
     * 导入人送其他费用数据
     *
     * @return
     */
    @ApiOperation(value = "导入人送其他费用数据", notes = "导入人送其他费用数据", httpMethod = "POST")
    @PostMapping("/importSdOtherExpensisesExcel")
    public RestfulResponse<Object> importSdOtherExpensisesExcel(@RequestBody String data, @RequestHeader("Authorization") String token) {
        LOGGER.info("ExcelController.importSdOtherExpensisesExcel（导入人送其他费用数据） params : {} ", data);
        RestfulResponse<Object> resultResponse = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            // 校验-1
            if (verifyStringData(data, resultResponse)) {
                return resultResponse;
            }
            Map<String, Object> sdOtherExpensisesTmplateMap = excelControllerMapCommon.getSdOtherExpensisesTmplateMap(true);
            ImportUtil<PsupOtherExpensisesVO> importUtil = new ImportUtil().setMapperKeyAreTitle(false);
            //将信息导成实体
            importUtil.importToData(PsupOtherExpensisesVO.class, data, sdOtherExpensisesTmplateMap);
            //将数据导入数据库
            List<PsupOtherExpensisesVO> dataEntity = importUtil.getDataEntity();

            // 校验是否有数据
            if (verifyDataEntity(dataEntity, resultResponse)) {
                return resultResponse;
            }
            // 校验是否有数据
            List<String> resultStr = psupOtherExpensisesService.createBatchOtherExpensises(dataEntity, token);
            if (verifyErrorList(resultStr, resultResponse)) {
                return resultResponse;
            }
        } catch (BaseException e) {
            LOGGER.error("ExcelController.importSdOtherExpensisesExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("ExcelController.importSdOtherExpensisesExcel ERROR Message : {} ", e);
            resultResponse.setCode(CommonEnum.ERROR.getCode());
            resultResponse.setMessage(CommonEnum.ERROR.getText());
        }
        return resultResponse;
    }

    /**
     * 人送其他费用数据导出
     *
     * @return
     */
    @ApiOperation(value = "人送其他费用数据导出", notes = "人送其他费用数据导出", httpMethod = "POST")
    @PostMapping("/exportSdOtherExpensisesExcel")
    public RestfulResponse<String> exportSdOtherExpensisesExcel(@RequestBody Map<String, Object> condition) {
        Map<String, Object> sdOtherExpensisesTmplateMap = excelControllerMapCommon.getSdOtherExpensisesTmplateMap(false);
        List<String> mapVal = ExcelCommon.getMapVal(sdOtherExpensisesTmplateMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<PsupOtherExpensisesVO> voList = psupOtherExpensisesService.querySdOtherExpensisesByCondition(condition);
        // 导出Excel
        return commonExportExcelResult("人送其他数据导出", titles, voList, sdOtherExpensisesTmplateMap, "_人送其他数据导出");
    }


    /**
     * 报价单明细数据转存导出
     *
     * @return
     */
    @ApiOperation(value = "报价单明细数据转存导出", notes = "报价单明细数据转存导出", httpMethod = "POST")
    @PostMapping("/exportQuoteDetailForExcel")
    public RestfulResponse<String> exportQuoteDetailForExcel(@RequestBody List<QuoteDtl> quoteDetailList) {
        Map<String, Object> newQuoteMap = null;
        if (CollectionUtils.isEmpty(quoteDetailList)) {
            newQuoteMap = excelControllerMapCommon.getNewQuoteExcelTemplate(false);
        } else {
            QuoteDtl quoteDtl = quoteDetailList.get(0);
            if (Objects.isNull(quoteDtl.getFeeId())) {
                newQuoteMap = excelControllerMapCommon.getNewQuoteExcelTemplate(false);
            } else {
                newQuoteMap = excelControllerMapCommon.getNewQuoteExcelTemplate(true);
            }
        }
        List<String> mapVal = ExcelCommon.getMapVal(newQuoteMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        // 导出Excel
        return commonExportExcelResult("报价单明细数据导出", titles, quoteDetailList, newQuoteMap, "_报价单明细数据导出");
    }

    /**
     * 开票申请数据数据导出
     *
     * @return
     */
    @ApiOperation(value = "开票申请数据数据导出", notes = "开票申请数据数据导出", httpMethod = "POST")
    @PostMapping("/exportInvoiceApplyDataExcel")
    public RestfulResponse<String> exportInvoiceApplyDataExcel(@RequestBody Map<String, Object> condition) {
        Map<String, Object> invoiceApplyMap = excelControllerMapCommon.getInvoiceApplyExportMap();
        List<String> mapVal = ExcelCommon.getMapVal(invoiceApplyMap);
        String[] titles = mapVal.toArray(new String[mapVal.size()]);
        List<InvoiceApplyExcelVO> voList = invoiceApplyService.exportInvoiceApplyDataByCondition(condition);
        // 导出Excel
        return commonExportExcelResult("_开票申请数据数据导出", titles, voList, invoiceApplyMap, "_开票申请数据数据导出");
    }
}